package com.congwulin.wechat.service;

import com.congwulin.wechat.entity.user.User;
import com.congwulin.wechat.mapper.user.UserMapper;
import com.congwulin.wechat.mapper.user.UserPersistent;
import com.congwulin.wechat.util.service.vo.VOPersistent;
import com.congwulin.wechat.util.service.vo.VOSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserMapper mapper;

    public List<User> saveUser(List<User> list){
        VOPersistent voPersistent = new VOPersistent(new UserPersistent(mapper));
        VOSaveService service = new VOSaveService(voPersistent);
        return (List<User>)service.save(list);
    }

    public User getUserInfo(User user){
        User newUser = mapper.selectByAccountAndPassword(user);
        return newUser;
    }

    public User getUserByID(String id){
        return mapper.selectByPrimaryKey(id);
    }
}
